const chalk = require('chalk');
const { server } = require("../config");
const moment = require("moment");

const log = console.log;

function serverTip() {
  const basicTip = `[${server.name}]：`;
  const port = Number(server.port) === 80 ? '' : `:server.port`;
  
  log(
    basicTip,
    moment().format("YYYY-MM-DD HH:mm:ss"),
    chalk.bold.green('express server is running')
  );

  log(
    basicTip, 
    moment().format("YYYY-MM-DD HH:mm:ss"),
    chalk.bold('服务请求地址如下：')
  );
  
  log(` 
    ${chalk.bold.blue('http://localhost'+port)}
    ${chalk.bold.blue('http://127.0.0.1'+port)}
  `);
}

module.exports = serverTip;